package com.yanqu.road.server.manager.config;

import com.yanqu.road.entity.config.vehicle.VehicleInfo;
import com.yanqu.road.logic.bussiness.config.VehicleBussiness;
import com.yanqu.road.server.TempMgr;

import java.util.Map;

public class VehicleMgr extends TempMgr {

    private static Map<Integer, VehicleInfo> vehicleInfoMap;

    public static Map<Integer, VehicleInfo> getVehicleInfoMap() {
        return vehicleInfoMap;
    }

    @Override
    public boolean reloadConfig() throws Exception {
        vehicleInfoMap = VehicleBussiness.getVehicleInfoMap();
        return true;
    }

    @Override
    public boolean reloadData() throws Exception {
        return true;
    }

    @Override
    public boolean init() throws Exception {
        return reload();
    }

    @Override
    public boolean stop() {
        return false;
    }

    /**
     * 是否是可排行的珍兽类型
     */
    public static boolean canJoinRank(int templateId) {
        VehicleInfo vehicleInfo = vehicleInfoMap.get(templateId);
        if (vehicleInfo == null) {
            return false;
        }
        if (vehicleInfo.getStudyTypeList().size() == 1 && vehicleInfo.getStudyTypeList().get(0) == 0) {
            return false;
        }
        return true;
    }
}
